package com.zr.util

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

//拦截器配置类，需要@Configurator标签以及实现WebMvcConfigurator接口
@Configuration
open class TokenInterceptorConfig :WebMvcConfigurer{

    @Autowired
    private val tokenInterceptor:TokenInterceptor?=null

    override fun addInterceptors(registry: InterceptorRegistry) {
        //获得注册器对象
        val registration=registry.addInterceptor(tokenInterceptor)
        //设置所有路径的请求都进行拦截，除了login和logout
        registration.addPathPatterns("/**").excludePathPatterns("/sys/user/login","sys/user/logout","/client/LoginCustomer")
    }
}